package com.zw.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zw.dao.ShoppingMapper;
import com.zw.entity.Shopping;
import com.zw.entity.ShoppingExample;
import com.zw.service.ShoppingService;

@Service
public class ShoppingServiceImpl implements ShoppingService{

	@Autowired
	private ShoppingMapper shoppingMapper;
	
	@Override
	@Transactional
	public int insertShopping(Shopping shopping) {
		return shoppingMapper.insert(shopping);
	}
	
	@Cacheable(value="ShoppingCacheByUid")
	@Override
	public List<Shopping> selectShopping(int uId) {
		ShoppingExample example=new ShoppingExample();
		example.or().andUseridEqualTo(uId);
		return shoppingMapper.selectByExample(example);
	}

	@Override
	public Shopping selectShoppingBySid(int sId) {
		return shoppingMapper.selectByPrimaryKey(sId);
	}

	@Transactional
	@Override
	public int deleteShopping(int sId) {
		return shoppingMapper.deleteByPrimaryKey(sId);
	}

	
}
